package com.ruoyi.tracker.controller;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.tracker.domain.VehicleLocation;
import com.ruoyi.tracker.service.VehicleLocationService;
import com.ruoyi.tracker.vo.LocationQueryVo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

/**
* 车辆位置表(tb_Vehicle_location)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/location")
public class VehicleLocationController {
    @Autowired
    private VehicleLocationService vehicleLocationService;

    /**
     * 车辆位置上报接口
     */
    @PostMapping(value = "/report", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE})
    public AjaxResult report(
            @RequestBody VehicleLocation vehicleLocation
    ){
        return AjaxResult.success("上报成功", vehicleLocationService.report(vehicleLocation));
    }
    /**
     * 查询车辆5公里开外的车辆
     */
    @PostMapping("/query/{vehicleLongitude}/{vehicleLatitude}")
    public AjaxResult query(
            @PathVariable(name = "vehicleLongitude")Double vehicleLongitude,
            @PathVariable(name = "vehicleLatitude")Double vehicleLat
    ){
        return AjaxResult.success("查询成功", vehicleLocationService.selectQuery(vehicleLongitude,vehicleLat));
    }
}
